<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('保险金内容列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="benefitId" name="benefitId" th:value="${benefitId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>用户姓名：</label>
                                <input type="text" name="userName"/>
                            </li>
                            <li>
                                <label>申报类别：</label>
                                <select name="benefitType" th:with="type=${@dict.getType('basic_benefit_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>岗位属性：</label>
                                <select name="postType" th:with="type=${@dict.getType('post_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>编制情况：</label>
                                <select name="workDuty" th:with="type=${@dict.getType('basic_work_duty')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="record:benefit:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="record:benefit:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="record:benefit:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="importExcel()"  shiro:hasPermission="record:benefit:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()"  shiro:hasPermission="record:benefit:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-table-fixed-columns-js" />
     <script th:inline="javascript">
        var prefix = ctx + "record/benefit/content";

        var datas = [[${@dict.getType('basic_benefit_type')}]];
        var posts = [[${@dict.getType('post_type')}]];
        var workDutys = [[${@dict.getType('basic_work_duty')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "保险金内容",
                fixedColumns: true,
                fixedNumber: 6,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'contentId',
                    title: '内容id',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '用户姓名',
                    sortable: true
                },
                {
                    field: 'idCard',
                    title: '身份证号',
                    sortable: true
                },
                {
                    field: 'benefitType',
                    title: '申报类别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'postType',
                    title: '岗位属性',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(posts, value);
                    }
                },
                {
                    field: 'workDuty',
                    title: '编制情况',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(workDutys, value);
                    }
                },
                {
                    field: 'a1',
                    title: '机关事业养老(单位)'
                },
                {
                    field: 'a2',
                    title: '机关事业养老(个人)'
                },
                {
                    field: 'b1',
                    title: '企业养老(单位)'
                },
                {
                    field: 'b2',
                    title: '企业养老(个人)'
                },
                {
                    field: 'c1',
                    title: '失业(单位)'
                },
                {
                    field: 'c1',
                    title: '失业(个人)'
                },
                {
                    field: 'd1',
                    title: '医疗(单位)'
                },
                {
                    field: 'd2',
                    title: '医疗(个人)'
                },
                {
                    field: 'e',
                    title: '工伤'
                },
                {
                    field: 'f1',
                    title: '职业年金(单位)'
                },
                {
                    field: 'f2',
                    title: '职业年金(个人)'
                },
                {
                    field: 'g',
                    title: '公务员医疗'
                },
                {
                    field: 'h1',
                    title: '企业年金(单位)'
                },
                {
                    field: 'h2',
                    title: '企业年金(个人)'
                },
                {
                    field: 'j1',
                    title: '公积金(单位)'
                },
                {
                    field: 'j2',
                    title: '公积金(个人)'
                },
                {
                    field: 'k',
                    title: '滞纳金'
                },
                {
                    field: 'remark',
                    title: '备注'
                }]
            };
            $.table.init(options);
        });

        function add(){
            var benefitId = $("#benefitId").val();
            $.operate.add(benefitId);
        }

        function importExcel() {
            layer.open({
                type: 1,
                area: ['400px', '230px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: '导入保险金内容数据',
                content: $('#importTpl').html(),
                btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
                // 弹层外区域关闭
                shadeClose: true,
                btn1: function(index, layero){
                    var file = layero.find('#file').val();
                    if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))){
                        $.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
                        return false;
                    }
                    var index = layer.load(2, {shade: false});
                    $.modal.disable();
                    var formData = new FormData(layero.find('form')[0]);
                    formData.set("benefitId", $("#benefitId").val());
                    $.ajax({
                        url: table.options.importUrl,
                        data: formData,
                        cache: false,
                        contentType: false,
                        processData: false,
                        type: 'POST',
                        success: function (result) {
                            if (result.code == web_status.SUCCESS) {
                                $.modal.closeAll();
                                $.modal.alertSuccess(result.msg);
                                $.table.refresh();
                            } else if (result.code == web_status.WARNING) {
                                layer.close(index);
                                $.modal.enable();
                                $.modal.alertWarning(result.msg)
                            } else {
                                layer.close(index);
                                $.modal.enable();
                                $.modal.alertError(result.msg);
                            }
                        }
                    });
                }
            });
        }
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果人员保险金已经存在，更新这条数据。"> 是否更新已经存在的人员保险金信息
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>